package com.wc.alorithm_luogu.P1553;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/23 18:35
 * @description https://www.luogu.com.cn/problem/P1553
 * 数字反转（升级版）
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String num = sc.nextLine();

        boolean contains = num.contains(".");
        String[] splits;
        if (contains) {
            splits = num.split("\\.");
            String left = splits[0];
            String right = splits[1];

            String reverseLeft = reverseNum(left);
            String reverseRight = reverseNum(right);

            // 小数部分是去掉前面的0
            while (reverseRight.length() != 1 && reverseRight.charAt(reverseRight.length() - 1) == '0') {
                reverseRight = reverseRight.substring(0, reverseRight.length() - 1);
            }

            System.out.println(reverseLeft + "." + reverseRight);
            return;
        }
        contains = num.contains("/");
        if (contains) {
            splits = num.split("/");
            String left = splits[0];
            String right = splits[1];

            String reverseLeft = reverseNum(left);
            String reverseRight = reverseNum(right);

            System.out.println(reverseLeft + "/" + reverseRight);
            return;
        }
        contains = num.contains("%");
        if (contains) {
            splits = num.split("%");
            String left = splits[0];
            String reverseLeft = reverseNum(left);

            System.out.println(reverseLeft + "%");
            return;
        }
        String reverseNum = reverseNum(num);
        System.out.println(reverseNum);
    }

    public static String reverseNum(String num) {
        if ("0".equals(num)) {
            return num;
        }

        StringBuilder reverseNum = new StringBuilder(num);
        // 去掉后面的0
        while (reverseNum.charAt(reverseNum.length() - 1) == '0') {
            reverseNum.deleteCharAt(reverseNum.length() - 1);
        }
        reverseNum.reverse();

        return reverseNum.toString();
    }
}
